<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h3>编写任意个数字的求和、积的函数</h3>
    <script>
      //求和是sum  求积fun
      function sum() {
        var len = arguments.length;
        var sum = 0;
        for (var i = 0; i < len; ++i) {
          sum += arguments[i];
          document.write(arguments[i] + "+");
        }
        document.write("=" + sum + "<br>");
      }
      function fun() {
        var len = arguments.length;
        var fun = 1;
        for (var i = 0; i < len; ++i) {
          fun *= arguments[i];
        }
        document.write(fun + "<br>");
      }
      sum(135, 578, 254);
      sum(1, 2, 3, 4, 5, 6, 7, 8, 9);
      fun(12, 14);
      fun(68, 17, 86);
      fun(1, 2, 3, 4, 5, 6, 7);
    </script>
  </body>
</html>
